package com.sevennotes.classtable.ui.pages.recordpage

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.sevennotes.classtable.model.ClassRecordMonthStatis
import com.sevennotes.classtable.ui.pages.components.BarChartCard

@Composable
fun RecordStatisticsPage(
  classRecordStatis: List<Pair<String, List<ClassRecordMonthStatis>>>,
) {
  val maxValue = remember(classRecordStatis) {
    classRecordStatis.maxOfOrNull {
      it.second.maxOfOrNull { it.total } ?: 0
    }
  }
  /**
   * 统计表格显示
   */
  LazyColumn(modifier = Modifier.fillMaxWidth()) {
    items(classRecordStatis) { statisItem ->
      BarChartCard(
        modifier = Modifier.padding(8.dp),
        year = statisItem.first,
        data = statisItem.second,
        maxValue = maxValue
      )
    }
  }
}